﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PhoneManager
{
    public partial class FrmReadSMS : PhoneManager.FrmDefault
    {
        public FrmReadSMS()
        {
            InitializeComponent();
        }

        private void BntCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        public string Number { get; set; }
        public string NamePhonebook { get; set; }
        public DateTime? DateTime { get; set; }
        public TimeSpan? TimeZone { get; set; }
        public string Message { get; set; }
        public string LocationBox { get; set; }

        private void FrmReadSMS_Load(object sender, EventArgs e)
        {
            TxtNumber.Text = this.Number;
            TxtName.Text = this.NamePhonebook;
            string FMT = Properties.Settings.Default.DefaultDateFmt;
            FMT = FMT.Replace("DD", "dd").Replace("YYYY", "yyyy");
            if (this.DateTime.HasValue)
            {
                TxtDtHr.Text = this.DateTime.Value.ToString(FMT + " HH:mm:ss");
            }
            else
            {
                TxtDtHr.Text = "";
            }
            if (this.TimeZone.HasValue)
            {
                if (this.TimeZone.Value.TotalMinutes < 0)
                {
                    TxtTZ.Text = "-"  + this.TimeZone.Value.Hours.ToString().PadLeft(2, '0') + ":" + this.TimeZone.Value.Minutes.ToString().PadLeft(2, '0');
                }
                else
                {
                    TxtTZ.Text = this.TimeZone.Value.Hours.ToString().PadLeft(2, '0') + ":" + this.TimeZone.Value.Minutes.ToString().PadLeft(2, '0');
                }
            }
            else
            {
                TxtTZ.Text = "";
            }

            TxtMsg.Text = this.Message;
            LblLoc.Text = this.LocationBox;
        }

        private void FrmReadSMS_Shown(object sender, EventArgs e)
        {
            BntCancel.Focus();
        }

    }
}
